<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../vue.js"></script>
    <style>
        .box {
            height: 100px;
            width: 100px;
            background-color: red;
        }
    </style>
</head>

<body>
    <div id="app">
        <a href="http://www.baidu.com" @click.prevent="fn4">百度一下(阻止默认事件)</a>
        <div @click="fn1" class="box">
            <button @click.stop="fn2">点击冒泡</button>
        </div>
        <div>
            <button @click.once="one">点击</button>
        </div>
        <div>
            姓名: <input type="text" v-model="name" @keyup.esc="clear">
        </div>
    </div>
</body>
<script>
    new Vue({
        el: '#app',
        data: {
            name: ''
        },
        methods: {
            clear() {
                console.log("-------clear-----");
                this.name = ''
            },
            one() {
                console.log("--------one---------");
            },
            fn1() {
                console.log('事件触发了-----fn1--');
            },
            fn2(e) {
                // e.stopPropagation();
                console.log('事件触发了-----fn2--');
            },
            fn4(e) {
                // e.preventDefault()
                console.log('事件触发了-------');
            },
        }
    })
</script>

</html>